package com.yanqu.road.server.cmd.union.cross;

import com.yanqu.road.pb.union.UnionProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.union.CrossUnionMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_UNION_CHANGE_APPLY_TITLE,desc = "")
public class CrossChangeUnionApplyTitleCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        UnionProto.ChangeUnionApplyTitleLimitReqMsg reqMsg = UnionProto.ChangeUnionApplyTitleLimitReqMsg.parseFrom(packet.getBytes());
        int title = reqMsg.getTitle();

        ret = CrossUnionMgr.changeApplyTitle(serverId, packet.getPlayerId(), title);
        UnionProto.ChangeUnionApplyTitleLimitRespMsg.Builder resp = UnionProto.ChangeUnionApplyTitleLimitRespMsg.newBuilder();
        resp.setRet(ret);
        resp.setTitle(title);
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_UNION_CHANGE_APPLY_TITLE, resp));

    }

    @Override
    public void sendData() {

    }
}
